package com.heima.wemedia.controller.v1;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMediaDto;
import com.heima.wemedia.service.WmMediaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WMmediaController {
    @Autowired
    private WmMediaService wmMediaService ;
    @PostMapping("upload_picture")
    //图片上传
    public ResponseResult upload (MultipartFile multipartFile){
        return wmMediaService.upload(multipartFile) ;
    }
    //素材管理查看列表
    @PostMapping("/list")
    public ResponseResult findLinst(@RequestBody WmMediaDto dto){
        return wmMediaService.findLinst(dto);
    }
    //图片删除功能
    @GetMapping("/del_picture/{id}")
    public ResponseResult del(@PathVariable Integer id){
        return wmMediaService.del(id);

    }
    //取消收藏
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable Integer id){
        return  wmMediaService.cancelCollect(id);
    }
    //添加收藏
    @GetMapping("/collect/{id}")
    public  ResponseResult collect(@PathVariable Integer id){
        return wmMediaService.collect(id);
    }
}

